const app=getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    cardCur: 0,
    swiperList: [],
    iconList: [{
      id:0,
      icon: 'cardboardfill',
      color: 'red',
      name: '门票'
    }, {
      id:1,
      icon: 'recordfill',
      color: 'orange',
      name: '景点'
    }, {
      id:2,
      icon: 'picfill',
      color: 'yellow',
      name: '攻略'
    }, {
      id:3,
      icon: 'noticefill',
      color: 'olive',
      name: '导游'
    }, {
      id:4,
      icon: 'upstagefill',
      color: 'cyan',
      name: '地图'
    }, {
      id:5,
      icon: 'clothesfill',
      color: 'blue',
      name: '特产'
    }],
    gridCol:3,
    jindianList:[],
    page:0,
    limit:4
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getSwiperList();
    this.getJinDianList();
  },

  //请求轮播图
  getSwiperList(){
    wx.cloud.callFunction({
      name:"GetSwiperList" 
    }).then(res=>{
      this.setData({
        swiperList:res.result.data
      })
    })
  },
  
  //请求景点列表
  async getJinDianList(){
    const {limit,page}=this.data;
    await app.showLoading();
    wx.cloud.callFunction({
      name:'GetJinDianList', 
      data:{
        limit:limit,
        page:page
      }
    }).then(res=>{
      //console.log(res);
      wx.hideLoading();
      this.setData({jindianList:res.result.data});
    })
  },

  //导航栏跳转
  goNav(e){
    //console.log(e.target.dataset.idx);
    switch(e.currentTarget.dataset.idx){
      case 0:wx.navigateTo({url: '/pages/ticket/ticket'});
      case 1:wx.navigateTo({url: '/pages/JinDianList/JinDianlist'});
      case 2:wx.navigateTo({url: '/pages/gongLueList/gongLueList'});
      case 3:wx.navigateTo({url: '/pages/guideList/guideList'});
      case 4:wx.navigateTo({url: '/pages/map/map'});
      case 5:wx.navigateTo({url: '/pages/techan/techan'});
    }
  },
  //跳转列表页
  goList(){
    wx.navigateTo({url: '/pages/JinDianList/JinDianlist'})
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})